package sn.gandal.mobile.kalpet.adaptators;

import java.util.ArrayList;
import java.util.List;

import sn.gandal.mobile.kalpet.R;
import sn.gandal.mobile.kalpet.server.dto.HistoriqueDTO;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class HistoriqueAdapter extends BaseAdapter {

	List<HistoriqueDTO> listHistoriques= new ArrayList<HistoriqueDTO>();

	public Context context;

	public HistoriqueAdapter(Context context) {
		this.context = context;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return listHistoriques.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View view;
		if (convertView != null) {
			view = convertView;
		} else {
			LayoutInflater li = (LayoutInflater) context
					.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			view = li.inflate(R.layout.historique_list_view_adapter, null);
			if (position == 0) {
				/*LinearLayout ll = (LinearLayout) view
						.findViewById(R.id.histo_itemDetail);
				ll.setVisibility(View.VISIBLE);*/
				TextView generique = (TextView) view
						.findViewById(R.id.histo_generique);
				generique.setVisibility(View.VISIBLE);
			} 
				// View v=
				// LayoutInflater.from(context).inflate(R.layout.text_view_adapter,
				// null);
				TextView detail = (TextView) view
						.findViewById(R.id.histo_detail);
				TextView libelle = (TextView) view
						.findViewById(R.id.histo_libelle);
				TextView solde = (TextView) view.findViewById(R.id.histo_solde);
				TextView date = (TextView) view.findViewById(R.id.histo_date);
				
				HistoriqueDTO hs= listHistoriques.get(position);
				
				date.setText(hs.getDateTransaction());
				detail.setText(hs.getDetails()+hs.getLocalisation());
				libelle.setText(hs.getBeneficiaire());
				solde.setText(hs.getMontant());
			

		}

		return view;

	}

	public List<HistoriqueDTO> getListHistoriques() {
		return listHistoriques;
	}

	public void setListHistoriques(List<HistoriqueDTO> listHistoriques) {
		this.listHistoriques = listHistoriques;
	}
	
	

}
